package com.controller;

import com.model.Echarts;
import com.model.MyLog;
import com.service.MylogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("我的用户")
@RestController
@RequestMapping("/myLog")
public class MylogController {
    @Autowired
    private MylogService mylogService;

    @CrossOrigin
    @RequestMapping(value = "/addLog",method = RequestMethod.GET)
    public int addMyLog(@RequestBody MyLog myLog){
        System.out.println("添加log");
        return mylogService.addMyLog(myLog);
    }

    @CrossOrigin
    @RequestMapping(value = "/updateLog",method = RequestMethod.GET)
    public int updateLog(@RequestBody MyLog myLog){
        System.out.println("更新log");
        return mylogService.updateMyLog(myLog);
    }

    @CrossOrigin
    @RequestMapping(value = "/deleteLog",method = RequestMethod.GET)
    public int deleteLog(int userid){
        System.out.println("删除log");
        return mylogService.deleteMyLog(userid);
    }

    @CrossOrigin
    @RequestMapping(value = "/getLogByUserId",method = RequestMethod.GET)
    public MyLog getLogByUserid(int userid){
        System.out.println("根据id查询log");
        return mylogService.getMyLogByUserid(userid);
    }

    @CrossOrigin
    @RequestMapping(value = "/getLogByTime",method = RequestMethod.GET)
    public List<MyLog> getLogByTime(int data1, int data2){
        System.out.println("根据时间区域查询log");
        return mylogService.getMyLogByTime(data1,data2);
    }

    @CrossOrigin
    @ApiOperation(value = "获取分析信息")
    @RequestMapping(value = "/getWeekInfo" ,produces = "application/json;charset=utf-8",method = RequestMethod.PUT)
    public List<Echarts> getWeekInfo(MyLog myLog){
        System.out.println("进入分析方法");
        return mylogService.weekInfo(myLog);
    }

    @CrossOrigin
    @ApiOperation(value = "获取分析信息")
    @RequestMapping(value = "/getRankInfo" ,produces = "application/json;charset=utf-8",method = RequestMethod.PUT)
    public List<MyLog> getRankInfo(MyLog myLog){
        System.out.println("进入分析方法");
        return mylogService.rankInfo(myLog);
    }
}
